import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import '@/plugins/element.js'
import '@/api/mock.js'


// Vue.use(Button);
Vue.config.productionTip = false
router.beforeEach((to,from,next)=>{
 store.commit('getToken')
  const token=store.state.user.token
  if(!token && to.path!='/login'){
    next({path:'/login'})
  }else if(token && to.path==='/login'){
    next({path:'/'})
  }
  
  else{
    next()
  }
})
new Vue({
  router,
  store,
  render: h => h(App),
  created() {
    store.commit('addMune',router)
  },
}).$mount('#app')
